import request from '../../request/request'

// 获取药品列表
export function getMedicineList(params) {
  return request({
    url: '/medicineInfo/getMedicineInfo',
    method: 'post',
    data: params
  })
}

// 获取药品详情
export function getMedicineDetail(id) {
  return request({
    url: `/medicineInfo/detail/${id}`,
    method: 'get'
  })
}

// 添加药品
export function addMedicine(data) {
  return request({
    url: '/medicineInfo/add',
    method: 'post',
    data
  })
}

// 更新药品
export function updateMedicine(data) {
  return request({
    url: '/medicineInfo/update',
    method: 'put',
    data
  })
}

// 删除药品
export function deleteMedicine(data) {
  return request({
    url: '/medicineInfo/delete',
    method: 'delete',
    data
  })
}

// 导出药品信息
export function exportMedicine(data) {
  return request({
    url: '/medicineInfo/export',
    method: 'post',
    data,
    responseType: 'blob',
    headers: {
      'Content-Type': 'application/json',
      'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    },
    timeout: 60000
  })
}

// 导入药品信息
export function importMedicine(formData) {
  return request({
    url: '/medicineInfo/import',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// 下载药品导入模板
export function downloadMedicineTemplate() {
  return request({
    url: '/medicineInfo/template',
    method: 'get',
    responseType: 'blob',
    headers: {
      'Accept': 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
    }
  })
}

// 获取通用分类列表
export function getCommonCategories() {
  return request({
    url: '/medicineInfo/commonCategories',
    method: 'get'
  })
}

// 获取处方分类列表
export function getPrescriptionCategories() {
  return request({
    url: '/medicineInfo/prescriptionCategories',
    method: 'get'
  })
}

